//
//  ViewController.m
//  CustomSeque
//
//  Created by Home on 2/2/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
// *****************************************************************************
// This controller is attached to the storyboard controller titled "Third Menu"
// *****************************************************************************


#import "ViewController.h"
#import "FlashCardViewController.h"
#import "FlashCards.h"
#import "DebugMacro.h"

@implementation ViewController
@synthesize swipeLeftRecognizer;


UIGestureRecognizer *recognizer;

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    UIGestureRecognizer *recognizer;
    // RIGHT SWIPE
    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self 
                                                           action:@selector(handleSwipeFrom:)];
    [self.view addGestureRecognizer:recognizer];
    // LEFT SWIPE
    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    
    self.swipeLeftRecognizer = (UISwipeGestureRecognizer *)recognizer;
    
    swipeLeftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
    
    [self.view addGestureRecognizer:swipeLeftRecognizer];
    
    self.swipeLeftRecognizer = (UISwipeGestureRecognizer *)recognizer;
    
    
}

- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
    if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
        // load a different viewController
        
        
        // Before loading the flashcard view, set the Flashcard Model back to the first card
        [FlashCards sharedFlashCards].currentCardNumber = 1;

        
        FlashCardViewController *flashCard = [[FlashCardViewController alloc] init];
        // [flashCard setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
        //[flashCard setModalTransitionStyle:UIModalTransitionStylePartialCurl];
        [flashCard setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
        [self presentModalViewController:flashCard animated:YES];
        
        
        // [[NSBundle mainBundle] loadNibNamed:@"FlashCardViewController" owner:self options:nil];
        
    } else {
        // load an even different viewController
        
        
        [self dismissModalViewControllerAnimated:NO];
    }
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
	[super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end
